<%--
  Created by IntelliJ IDEA.
  User: SamZhao
  Date: 2016/12/6
  Time: 19:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ include file="/WEB-INF/jsp/include.inc.jsp"%>


<!-- END JS -->


<!-- BEGIN SECTION -->
<section id="container" class="">

    <!-- BEGIN MAIN CONTENT -->
    <section id="main-content">
        <section class="wrapper site-min-height">
            <!-- BEGIN ROW  -->
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">
                            <span class="label label-primary">护士站管理</span>
                            <span class="tools pull-right">
                           <a href="javascript:;" class="fa fa-chevron-down"></a>
                           <a href="javascript:;" class="fa fa-times"></a>
                           </span>
                        </header>
                        <div class="panel-body">
                            <div class="modal fade" id="myModal3" >
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title">确认!</h4>
                                        </div>
                                        <input type="hidden" name="id" id="id"/>
                                        <div class="modal-body" id="erroText">
                                            确定删除？
                                        </div>
                                        <div class="modal-footer">
                                            <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                                            <button class="btn btn-warning" type="button" id="deleteConfirm" onclick="deleteConfirm();">确定</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal fade" id="info"  >
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title">提示</h4>
                                        </div>
                                        <div class="modal-body" id="infoText">
                                            提交成功!
                                        </div>
                                        <div class="modal-footer">
                                            <button class="btn btn-success" type="button" data-dismiss="modal">确定</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="adv-table">
                                <div class="clearfix">
                                    <div class="btn-group">
                                        <a href="/nursestation/addNursestation.html">
                                            <button id="editable-sample_new" class="btn btn-success green">
                                                新增<i class="fa fa-plus"></i>
                                            </button>
                                        </a>
                                    </div>
                                </div>
                                <div class="space15"></div>

                                <table class="display table table-bordered table-striped" id="example">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>护士站</th>
                                        <th style="width: 290px;">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        <c:forEach items="${nurlist }" var="item">
                                            <tr class="gradeX">
                                                <td>${item.id }</td>
                                                <td class="hidden-phone">${item.name } </td>
                                                <td class="center hidden-phone">
                                                    <a class="edit" href="/nursestation/editNursestation.html?id=${item.id }"><span class="label label-primary">编辑</span></a>
                                                    <a class="delete" href="javascript:void(0);" onclick="deleteRole(${item.id });"><span class="label label-danger">删除</span></a>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                    </tbody>
                                    <%--<tfoot>--%>
                                        <%--<tr>--%>
                                            <%--<th>Rendering engine</th>--%>
                                            <%--<th class="hidden-phone">Browser</th>--%>
                                            <%--<th>Platform(s)</th>--%>
                                            <%--<th class="hidden-phone">Engine version</th>--%>
                                            <%--<th class="hidden-phone">CSS grade</th>--%>
                                        <%--</tr>--%>
                                    <%--</tfoot>--%>
                                </table>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
            <!-- END ROW  -->
        </section>
    </section>
    <!-- END SECTION -->

    <!-- BEGIN FOOTER -->
    <footer class="site-footer">
        <div class="text-center">
            2016 &copy; BMS4.0 by <a href="" target="_blank">SamZhao</a>.
            <a class="go-top">
                <i class="fa fa-angle-up"></i>
            </a>
        </div>
    </footer>
    <!-- END FOOTER  -->
</section>
<script type="text/javascript">

    function deleteRole(id){
        $("#id").val(id);
        $("#myModal3").modal("show");
    }

    function deleteConfirm(){
        $("#myModal3").modal("hide");
        $.ajax({
            type: "POST",
            url: "/nursestation/deleteNursestation.html?id="+ $("#id").val(),
            async: false,
            error: function() {
                $("#infoText").html("网络异常!");
                $("#info").modal("show");
            },
            success: function(data) {
                if(data == 'success'){
                    $("#infoText").html("删除成功!");
                    $("#info").modal("show");

                    window.setInterval(function()//延迟进行跳转
                    {
                        intervalRun();
                    }, 500);
                }else{
                    $("#infoText").html("删除出错!");
                    $("#info").modal("show");
                }

            }
        });
    }

    function intervalRun(){
        $("#info").modal("hide");
        window.location = "/nursestation/list.html";
    }

    $(function(){
        $("#myModal3").modal("hide");
        $("#info").modal("hide");

    });

</script>